import QtQuick 2.0
import "../components"

Item {

    id: root
    property int areaId: 0
    anchors.fill: parent

    // 检测偏差
    Row{
        spacing: -1
        Item{
            height: 40*dp
            width: 40*dp
            Text {
                text: "区域"
                font.pixelSize: config.fontsize
                anchors.centerIn: parent
            }
        }
        PushButton{
            title: "A"
            width: 100*dp
            text_color: "#333333"
            text_color_select: "white"
            button_border: "#EEEEEE"
            button_color: "white"
            button_color_select: "#1677FF"
            radius: 0
            isSelected: areaId === 0
            onReleased: {
                areaId = 0
            }
        }PushButton{
            title: "B"
            width: 100*dp
            text_color: "#333333"
            text_color_select: "white"
            button_border: "#EEEEEE"
            button_color: "white"
            button_color_select: "#1677FF"
            radius: 0
            isSelected: areaId === 1
            onReleased: {
                areaId = 1
            }
        }PushButton{
            title: "C"
            width: 100*dp
            text_color: "#333333"
            text_color_select: "white"
            button_border: "#EEEEEE"
            button_color: "white"
            button_color_select: "#1677FF"
            radius: 0
            isSelected: areaId === 2
            onReleased: {
                areaId = 2
            }
        }PushButton{
            title: "D"
            width: 100*dp
            text_color: "#333333"
            text_color_select: "white"
            button_border: "#EEEEEE"
            button_color: "white"
            button_color_select: "#1677FF"
            radius: 0
            isSelected: areaId === 3
            onReleased: {
                areaId = 3
            }
        }PushButton{
            title: "E"
            width: 100*dp
            text_color: "#333333"
            text_color_select: "white"
            button_border: "#EEEEEE"
            button_color: "white"
            button_color_select: "#1677FF"
            radius: 0
            isSelected: areaId === 4
            onReleased: {
                areaId = 4
            }
        }PushButton{
            title: "F"
            width: 100*dp
            text_color: "#333333"
            text_color_select: "white"
            button_border: "#EEEEEE"
            button_color: "white"
            button_color_select: "#1677FF"
            radius: 0
            isSelected: areaId === 5
            onReleased: {
                areaId = 5
            }
        }
    }
    CustomComboBox{
        title: "通道"
        textWidth: 36*dp
        editWidth: 120*dp
        x: parent.width - 155*dp
        model: ["FAM", "ROX", "VIC", "CY5"]
    }

    GridTable{
        id: table
        y:60*dp
        columnCount: 8
        rowCount: 7
        title: ["", "", "数据", "", "", "最大值", "均值", "操作"]
        title2: ["区域", "A", "B", "C", "D", "E", "F", "合计"]
    }
    Item{      // 操作的按钮 (直接覆盖表格了)
        y: 60*dp + table.titleHeight
        x: table.width - width
        height: 7*table.rowHeight*dp
        width: (table.width-table.titleWidth) / table.columnCount
        MouseArea{
            anchors.fill: parent
        }
        Repeater{
            model: 7
            Item{
                height: table.rowHeight
                width: parent.width
                y: table.rowHeight * index
                PushButton{
                    title: "读取"
                    text_color: "#1677FF"
                    width: 45*dp; height: 20*dp
                    anchors.centerIn: parent
                    anchors.horizontalCenterOffset: Math.min(-25*dp, -parent.width / 7)
                    onReleased: {
                        console.log("读取行", index)
                    }
                }PushButton{
                    title: "设置"
                    text_color: "#1677FF"
                    width: 45*dp; height: 20*dp
                    anchors.centerIn: parent
                    anchors.horizontalCenterOffset: Math.max(25*dp, parent.width / 7)
                    onReleased: {
                        console.log("设置行", index)
                    }
                }
            }
        }


    }

}
